<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/layer.jsp" />
	<script type="text/javascript" src="${path}/style_lib/upload/swfupload/swfupload.js"></script>
	<%-- <script type="text/javascript" src="${path}/style_lib/upload/swfupload/swfupload.queue.js"></script> --%>
	<script type="text/javascript" src="${path}/style_lib/upload/swfupload/fileprogress.js"></script>
	<script type="text/javascript" src="${path}/style_lib/upload/swfupload/handlers.js"></script>
 <script type="text/javascript">
 $(function() {
	 $("select[name='save_user_id']").val('${seal.save_user_id}');
	 $("select[name='seal_type_id']").val('${seal_new.seal_type_id}');
	 if('${seal.true_code}'!=""){
	 	$("input[name='true_code']").attr("readonly","readonly");
	 }
		$("#form1").validate({
			rules : {
				'name' : {
					required : true
				},
				'bank_name' : {
					required : true
				},
				'seal_type_id' : {
					required : true
				},
				'seal_type_config_id' : {
					required : true
				},
				'save_user_id' : {
					required : true
				},
				'title' : {
					required : true,
					maxlength:100
				},
				'desc_s' : {
					maxlength:100
				},
				'snote' : {
					maxlength:255
				},
				'true_code':{
					digits:true,
					minlength:9,
					maxlength:9,
					remote:{
						type:"POST",
	               		url	:"${path}/ix/seal/news/apply/unique_code.htm?seal_new_id=${seal_new._id}"   
					}
				}
			},
			messages :{
				true_code:{remote :"该编码已存在，请重新输入！"}
			}
		});
		setTypeConfig();
	});
 function uploadSuccess(file, serverData) {
	        var end = $.parseJSON(serverData);
	        $("#main_pic").html("<img src='${path}/img/"+end.file_id+".htm?mh=150&mw=150'/>");
			$("#pic_msg").val(end.file_id);
		}
        $(function(){
            var upload1 = new SWFUpload({
				
				// Backend Settings
				upload_url : "${path}/swfupload.htm",
				//post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
				// File Upload Settings
				file_size_limit : "1200 MB",	// 100MB
				file_types : "*.gif;*.jpg;*.jpeg;*.bmp;*.png",
				file_upload_limit : 1,

				// Event Handler Settings (all my handlers are in the Handler.js file)
				swfupload_preload_handler : preLoad,
				swfupload_load_failed_handler : loadFailed,
				file_dialog_start_handler : fileDialogStart, 
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,

				// Button Settings
				button_placeholder_id : "filePicker",
				button_width: 80,
				button_height: 22,
				button_text:"选择图片",
				
				// Flash Settings
				flash_url : "${path}/style_lib/upload/swfupload/swfupload.swf",
				flash9_url : "${path}/style_lib/upload/swfupload/swfupload_fp9.swf",
			

				custom_settings : {
					progressTarget : "fsUploadProgress1"//,
					//cancelButtonId : "btnCancel1"
				},
				
				// Debug Settings
				debug: false
			});
		
        });
		//下拉 印章类型,弹出印章种类
	function setTypeConfig(){
		var seal_type_id = $("select[name='seal_type_id']").val();
		$.ajax({
			type:"post",
			cache:true,
			url:"${path}/ix/seal/type/configs_select.htm?seal_type_id="+seal_type_id,
			success:function(data){
				$("#seal_types").html(data);
				$("select[name='seal_type_config_id']").val('${seal_new.seal_type_config_id}');
			}
		
		});
	}
	
	function mysubmit() {
		$("#form1").submit();
	}
	</script>
</head>
<body>
<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
	<!-- 内容 -->
	<div>
		<form method="post" action="${path}/ix/seal/set/edit.htm" id="form1">
			<input type="hidden" name="file_id" value="${seal.file_id}" id="pic_msg"/>
			<input type="hidden" name="seal_id" value="${seal._id}"/>
			<h2>
				<div>
					修改印章
				</div>
				
			</h2>
			<table width="100%" class="lindex">
				<tr>
					<th align="right" style="min-width: 100px;">
						印章名称：
					</th>
					<td align="left" >
						<input name="name" type="text" value="${seal.name}" maxlength="32" />
					</td>
					<th align="right" >
						实物编号：
					</th>
					<td align="left" >
						<input name="true_code" type="text" maxlength="32" value="${seal.true_code}" />
					</td>
				</tr>
				<tr >
					<th align="right" >使用机构：</th>
					<td align="left" >${bank.name}(${bank.code})</td>
					<th align="right">
						 保管人员：
					</th>
					<td align="left" >
					<select name="save_user_id">
						<option value="">--请选择--</option>
							<c:forEach items="${userlist}" var="v">
								<option value="${v._id}">${v.uname}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th align="right">印章种类：</th>
					<td align="left">
						<select name="seal_type_id" onchange="setTypeConfig()">
							<option value="">--请选择--</option>
							<c:forEach items="${sealTypeList}" var="tp">
								<option value="${tp._id}">${tp.name}</option>
							</c:forEach>
						</select>
					</td>
					<th align="right">印章类型：</th>
					<td align="left" id="seal_types">
						
					</td>
				</tr>
				<tr>
					<th align="right">刻章字样：</th>
					<td align="left"><textarea name="title" rows="2" cols="60">${seal_new.title}</textarea></td>
					<th align="right">刻章原因：</th>
					<td align="left"><textarea name="desc_s" rows="2" cols="60">${seal_new.desc_s}</textarea></td>

				</tr>
				
				<tr>
					<th align="right">
						备注：
					</th>
					<td align="left" colspan="3">
						<textarea name="snote" type="text" maxlength="255" rows="2" cols="60">${seal.note}</textarea>
					</td>
				</tr>
				<tr>
					<th align="right">
						印章图片：
					</th>
					<td align="left" colspan="3">
					<div id="main_pic"><img src='${path}/img/${seal.file_id}.htm?mh=150&mw=150'/></div>
						<div id="uploader-demo">
						    <!--用来存放item-->
						    <div id="fileList" class="uploader-list"></div>
						    <div id="filePicker"></div>
						</div>
					</td>
				</tr>
				
			</table>
				<div class="options">
				<a href="javascript:mysubmit();" class="asave" >【保存】</a>
				    <a href="javascript:goBack();" class="asave" >【返回】</a>
			</div>
		</form>
		
	</div>
</body>
</html>